package com.cn.yz.springboot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cn.yz.springboot.model.SysUser;
import com.cn.yz.springboot.rabbitmq.sender.RabbitMQSender;

@RestController  
public class RabbitMQController {

	@Autowired
	private RabbitMQSender sender;
	
	@RequestMapping("/rabbitmq/sentMessage")
	public void sentMessage(){
		sender.send();
	}
	
	@RequestMapping("/rabbitmq/sentFanoutMessage")
	public void sentFanoutMessage(){
		SysUser user = new SysUser();
		user.setAccount("12334");
		user.setNickName("测试");
		user.setPassword("password");
		sender.sendToFanoutExchange("fanout-exchange", user);;
	}
	
	@RequestMapping("/rabbitmq/sentTopicMessage")
	public void sentTopicMessage(){
		SysUser user = new SysUser();
		user.setAccount("12334");
		user.setNickName("测试");
		user.setPassword("password");
		sender.sendToTopicExchange("topic-exchange", "1", user);
	}
}
